package mytaxis.client.menu;

import mytaxis.client.app.BookList;
import mytaxis.client.app.BookTaxi;
import mytaxis.client.app.MyTaxisClientApplication;
import mytaxis.client.app.Price;
import mytaxis.client.map.ClientMap;
import mytaxis.client.service.ComService;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import mytaxis.client.R;
import android.app.ListActivity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Menu extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ArrayList<String> list = new ArrayList<String>();

		try {
			InputStream in = getResources().openRawResource(R.raw.menu);
			if (in != null) {
				InputStreamReader tmp = new InputStreamReader(in);
				BufferedReader reader = new BufferedReader(tmp);
				String str;
				while ((str = reader.readLine()) != null) {
					list.add(str);
				}
			}
			in.close();

		} catch (java.io.FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, list));

	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		String item = (String) getListAdapter().getItem(position);

		if (item.compareTo("Ask for nearby taxi") == 0) {
				Intent i = new Intent(this, ClientMap.class);
				startActivity(i);
		}
		else if (item.compareTo("Book a taxi") == 0) {
			Intent i = new Intent(this, BookTaxi.class);
			startActivity(i);
		}
		else if (item.compareTo("View Booking Properties") == 0) {
			Intent i = new Intent(this, BookList.class);
			startActivity(i);
		}
		else if (item.compareTo("Calculate price") == 0) {
			
			Intent i = new Intent(this, Price.class);
			startActivity(i);
		}
	}}